package com.yunshu.yunshuapp.xianhuo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yunshu.yunshuapp.utils.YSUtils;

import java.io.IOException;
import java.util.Map;

/**
 * Created by zhouwenjie on 2017/2/11.
 */
@JsonIgnoreProperties
public class Xianhuo {

    //{"id":97954749268001,"type":0,"name":"sdf","typepic":"","productpic":"","createtime":1486460349000,
    // "updatetime":1486460349000,"place":"河北省","number":23,"company":"","tel":"123","mark":"","ext":"","channelname":"钢坯"}


    public static final int RecyclerViewItemTypeXianhuo = 0;
    public static final int RecyclerViewItemTypeCaigou = 1;

    @JsonProperty("id")
    private String xianhuoId ;
    private String type ;//0 现货 1采购
    @JsonProperty("name")
    private String contact ;
    private String typepic ;
    private String createtime ;
    private String updatetime ;
    private String place ;
    private String number ;
    private String company ;
    private String tel ;
    private String mark ; //备注
    private String channelname;
    private String ext;
    private String kucunpic;

    @JsonProperty("productcompany")
    private String factory;//工厂名字

    @JsonProperty("price")
    private String price;

    @JsonProperty("spec")
    private String specification;//规格

    @JsonProperty("material")
    private String quality;//材质

    private String productname;

    @JsonProperty("productplace")
    private String storehouse;

    private String companymark;

    private String companylink;

    private String productpic;
    private String productpic1;
    private String productpic2;

    private String userid;

    private String audit = "0";
    private String auditdesc = "";
    private String advert="";

    public String getXianhuoId() {
        return xianhuoId;
    }

    public void setXianhuoId(String xianhuoId) {
        this.xianhuoId = xianhuoId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getTypepic() {
        return typepic;
    }

    public void setTypepic(String typepic) {
        this.typepic = typepic;
    }

    public String getCreatetime() {

        return YSUtils.getDate(createtime);
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }

    public String getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(String updatetime) {
        this.updatetime = updatetime;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getCompany() {
        if (company == null ) return "";
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getTel() {
        if (tel == null ) return "";
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getMark() {
        if (mark == null ) return "";
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public String getChannelname() {
        if (channelname == null ) return "";
        return channelname;
    }

    public void setChannelname(String channelname) {
        this.channelname = channelname;
    }

    public String getProductpic() {
        if (productpic == null ) return "";
        return productpic;
    }

    public void setProductpic(String productpic) {
        this.productpic = productpic;
    }

    public String getExt() {
        if (ext == null ) return "";
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

    public String getKucunpic() {
        if (kucunpic == null ) return "";
        return kucunpic;
    }

    public void setKucunpic(String kucunpic) {
        this.kucunpic = kucunpic;
    }

    public String getFactory() {
        if (factory == null ) return "";
        return factory;
    }

    public void setFactory(String factory) {
        this.factory = factory;
    }

    public String getPrice() {
        if (price == null ) return "";
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getSpecification() {
        if (specification == null ) return "";
        return specification;
    }

    public void setSpecification(String specification) {
        this.specification = specification;
    }

    public String getQuality() {
        if (quality == null ) return "";
        return quality;
    }

    public void setQuality(String quality) {
        this.quality = quality;
    }

    public String getProductname() {
        if (productname == null ) return "";
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname;
    }

    public String getStorehouse() {
        if (storehouse == null ) return "";
        return storehouse;
    }

    public void setStorehouse(String storehouse) {
        this.storehouse = storehouse;
    }

    public String getCompanymark() {
        if (companymark == null ) return "";
        return companymark;
    }

    public void setCompanymark(String companymark) {
        this.companymark = companymark;
    }

    public String getCompanylink() {
        if (companylink == null ) return "";
        return companylink;
    }

    public void setCompanylink(String companylink) {
        this.companylink = companylink;
    }

    public String getProductpic1() {
        return productpic1;
    }

    public void setProductpic1(String productpic1) {
        this.productpic1 = productpic1;
    }

    public String getProductpic2() {
        return productpic2;
    }

    public void setProductpic2(String productpic2) {
        this.productpic2 = productpic2;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public Map serialize() {
        ObjectMapper mapper = new ObjectMapper();
        String resultString = null;
        Map map = null;
        try {
            resultString = mapper.writeValueAsString(this);
            map=mapper.readValue(resultString, Map.class);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return map;
    }

    public String getAudit() {
        return audit;
    }

    public void setAudit(String audit) {
        this.audit = audit;
    }

    public String getAuditdesc() {
        return auditdesc;
    }

    public void setAuditdesc(String auditdesc) {
        this.auditdesc = auditdesc;
    }

    public String serializeToString() {
        ObjectMapper mapper = new ObjectMapper();
        String resultString = null;
        Map map = null;
        try {
            resultString = mapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        return resultString;
    }

    public void setAdvert(String advert) {
        this.advert = advert;
    }
    public String getAdvert(){
        return this.advert;
    }
}
